<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>

<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> 
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>

<script type="text/javascript">

   function sosuo(){
	   var lpath=location.pathname;
	   $("#soform").attr("action",lpath, + "?pageNo=" + 1);
	   $("#soform").submit();
   }
   
   $(document).ready(function(){
		$(".checkfath").click(function(){
			$(".checkedchild").prop("checked",this.checked);
		})
		 
	})
	
   function importoExcel(state){
	   $('#exportForm input[name=state]').val(state);
	   $("#exportForm").submit();
   }      
	  
   
   function sub(){
	   var couriernum=$("#courierNum").val().trim();
	   if(couriernum==""){
		   alert("请输入正确的快递单号");
		   return false;
	   }
	   var con=confirm("是否确认");
	   if(con){
			   $.ajax({
				      type:"post",
					  dataType:"json",
					  data:$("form").serialize(),
					  url:"/prize/saveorupdate.do",
					  success:function(aj){
						  if(aj.success){
							  location.reload();//刷新页面
							  confirm(aj.msg);
						  }
					  }
				   });
		   }
	   }
	
   
   
   
   
   function chongzhi(id,state){
	   var res = confirm("是否确认");
	   if(res){
		   $.ajax({
			      type:"post",
				  dataType:"json",
				  data:{id:id,state:state},
				  url:"/prize/saveorupdate.do",
				  success:function(aj){
					  if(aj.success){
						  location.reload();
						  confirm(aj.msg);
					  }
				  }
			   }); 
	   }
	   
   }
   
   function dia(param){
	   dialog=art.dialog({
		   title:"邮寄奖品",
		   width:500,
		   lock:true,
		   content:document.getElementById("create")
	       
	   });
   }
   function send(id,state,giftName,contactName,contactAdd,contactTel,courierCompanyId,courierNum){
	   $("#id").val(id);
	   $("#state").val(state);
	   $("#giftName").val(giftName);
	   $("#contactName").val(contactName);
	   $("#contactAdd").val(contactAdd);
	   $("#contactTel").val(contactTel);
	   $("#courierCompanyId").val(courierCompanyId);
	   $("#courierNum").val(courierNum);
	   dia("邮寄奖品");
   }

 </script>


</head>
<body>
    <div class="panel panel-info panel-content">
      <div class="panel-heading" style="position: relative;">
			
			<form id="soform" method="post">
				<table>
					<tr>
						<td class="w80" style="padding-top: 5px">
							<label for="companyname" class="center-block">奖品名称或联系人：</label>
						</td>
						<td class="w150 ">
							<input type="text" class="form-control"   name="so_upname" value="${so_upname!}" id="so_search" placeholder="礼品名称或联系人">
						</td>
						<td class="w80" style="padding-top: 5px;">
							<label for="companyname" class="center-block">兑换状态：</label>
						</td>
						<td class="w120 ">
							<input  type="hidden"  id="so_setstate" name="so_setstate" value="${so_setstate!}">
							<select class="form-control"  name="so_state" onchange="$('#so_setstate').val($(this).find('option:selected').attr('data-so_setstate'))">
							    <option value=""  [#if !so_state?? || so_state=='' ]selected="selected"[/#if]>全部</option>
							    <option value="-1"[#if so_state?? && so_state=='-1']selected="selected"[/#if]>已放弃</option>
							    <option value="0" data-so_setstate="2" [#if so_state?? && so_state=='0' && so_setstate=='2']selected="selected"[/#if]>未寄出</option>
								<option value="0" data-so_setstate="1"  [#if so_state?? && so_state=='0' && so_setstate=='1']selected="selected"[/#if]>未充值</option>
								<option value="1" [#if so_state?? && so_state=='1']selected="selected"[/#if]>已寄出</option>
								<option value="2" [#if so_state?? && so_state=='2']selected="selected"[/#if]>已充值</option>
								<option value="3" [#if so_state?? && so_state=='3']selected="selected"[/#if]>已充入积分</option>

						    </select>
						</td>
						<td style="padding-left: 10px">
							<div class="input-group">
								<span class="input-group-btn" style="border: 1px solid #ddd;">
									<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
								</span>
							</div>
						</td>
						<td style="padding-left: 177px;font-size: 16px;font-family: inherit;color: inherit;">
							<input type="button" class="btn btn-info"  onclick="importoExcel('0')"         value="导出未处理兑换清单">
							<input type="button" class="btn btn-info"  onclick="importoExcel('-1,1,2,3')"  value="导出已处理兑换清单">
						</td>
					</tr>
				</table>
				</form>
				
			 <form id="exportForm" action="/prize/importRecoToExcel.do" method="post">
								<input type="hidden" name="state">
		     </form>
				
		</div>
      
      <table class="table table-hover table-bordered table-striped table-condensed">
         <tr>
           <th>序号</th>
           <th>中奖账户</th>
           <th>奖品名称</th>
           <th>中奖时间</th>
           <th>联系人</th>
           <th>联系电话</th>
           <th>邮寄地址</th>
           <th>状态</th>
           <th>操作</th>
           <th>快递公司</th>
           <th>快递单号</th>
         </tr>
         [#list pagination.list as record]
         <tr>
            <!-- 子选框<td style="text-align: center;"><input  class="checkedchild" type="checkbox" value="${record.id!}" ></td> -->
            <td align="center">${pagination.pageSize * (pagination.pageNo-1) + record_index+1!}</td>
            <td align="center">${record.mobile!}</td>
            <td align="center">[#if record.prizeSet??]${record.prizeSet.giftName!}[/#if]</td>
            <td align="center">[#if record.createtime?? ]${(record.createtime!)?string("yyyy-MM-dd")!}[/#if]</td>
            <td align="center">${record.contactName!}</td>
            <td align="center">${record.contactTel!}</td>
            <td align="center">${record.contactAdd!}</td>
            <td align="center">
            [#if record.state==-1]已放弃[/#if]
			[#if record.state==0]未[#if record.prizeSet.type==2]寄出[#else]充值[/#if][/#if]
			[#if record.state==1]已寄出[/#if]
			[#if record.state==2]已充值[/#if]
			[#if record.state==3]已充入积分[/#if]

            </td>
            <td align="center">
            [#if record.state==0 && record.prizeSet.type==2]
            <input type="button" value="确认寄出"  class="btn-info" onclick="send('${record.id!}',1,'${(record.prizeSet.giftName)!}','${record.contactName!}','${record.contactAdd!}','${record.contactTel!}','${record.courierCompanyId!}','${record.courierNum!}')">
            [/#if]
				[#if record.state==0 && record.prizeSet.type==1]
				<input type="button" value="确认充值"  class="btn-info" onclick="chongzhi('${record.id!}',2)">
				[/#if]
            </td>
            <td>
            [#if record.state==1]
            ${record.devCompanyName!}
            [/#if]
            </td>
           <td>
           [#if record.state==1]
            ${record.courierNum!}
           [/#if]
           </td>
            
         </tr>
         [/#list]
      </table>
         
         <div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>   
         
      </div>
      
      <div id="create" style="display: none;" >
         <form method="post" class="form-horizontal" role="form">
			<input type="hidden" name="id"     id="id">
			<input type="hidden" name="state"  id="state">
			<div class="form-group">
				<label class="col-sm-4 control-label" id="clickforpro">奖品名称</label>
				<div class="col-sm-8">
					<input  name="giftName" id="giftName" type="text" class="form-control" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-4 control-label">联系人</label>
				<div class="col-sm-8">
					<input type="text" name="contactName" id="contactName"  class="form-control" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-4 control-label">邮寄地址</label>
				<div class="col-sm-8">
					<input type="text" name="contactAdd"  id="contactAdd" class="form-control" >
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-4 control-label">联系电话</label>
				<div class="col-sm-8">
					<input type="text" name="contactTel"  id="contactTel" class="form-control" >
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-4 control-label">快递公司</label>
				<div class="col-sm-8">
					<select name="courierCompanyId" id="courierCompanyId" class="form-control">
                      [#list so_alldelivery as alldelivery]
						<option value="${alldelivery.id!}">${alldelivery.companyName!}</option>
					  [/#list]
					</select>
					[#--<input type="text"  name="devCompanyName"  id="devCompanyName" class="form-control" >--]
				[#--</div>--]
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-4 control-label">快递单号</label>
				<div class="col-sm-8">
					<input type="text"  name="courierNum"  id="courierNum" class="form-control" >
				</div>
			</div>
			
			<div class="form-group" style="margin-top: 15px;">
				<div class="col-sm-offset-3 col-sm-10">
					<input id="editsubmit" onclick="sub()" type="button"
						value="提交" class="btn btn-info"/>
				</div>
			</div>
	   </form>
      </div>
</body>
</html>